package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/guava-cache")
@Slf4j
public class GuavaCacheController {

    @GetMapping("/get/{key}")
    @Cacheable(value = "myCache",cacheManager = "caffeineCacheManager", key = "#key")
    public String get(@PathVariable String key) {
        // 这里可以替换为实际的业务逻辑
        log.info("走缓存获取" + key);
        return "Value for " + key;
    }

    @PostMapping("/put")
    public void put(@RequestParam String key, @RequestParam String value) {
        // 这里可以替换为实际的业务逻辑
    }
}